/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package impss;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Mikehood
 */
@Entity
@Table(name = "accessory")
@NamedQueries({@NamedQuery(name = "Accessory.findAll", query = "SELECT a FROM Accessory a"), @NamedQuery(name = "Accessory.findByAccessoryID", query = "SELECT a FROM Accessory a WHERE a.accessoryID = :accessoryID"), @NamedQuery(name = "Accessory.findByAccessoryType", query = "SELECT a FROM Accessory a WHERE a.accessoryType = :accessoryType"), @NamedQuery(name = "Accessory.findByAccessoryStandard", query = "SELECT a FROM Accessory a WHERE a.accessoryStandard = :accessoryStandard"), @NamedQuery(name = "Accessory.findByAccessoryInfo", query = "SELECT a FROM Accessory a WHERE a.accessoryInfo = :accessoryInfo"), @NamedQuery(name = "Accessory.findByAccessoryPrice", query = "SELECT a FROM Accessory a WHERE a.accessoryPrice = :accessoryPrice"), @NamedQuery(name = "Accessory.findByAfID", query = "SELECT a FROM Accessory a WHERE a.afID = :afID")})
public class Accessory implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "accessoryID")
    private Integer accessoryID;
    @Column(name = "accessoryType")
    private String accessoryType;
    @Column(name = "accessoryStandard")
    private String accessoryStandard;
    @Column(name = "accessoryInfo")
    private String accessoryInfo;
    @Column(name = "accessoryPrice")
    private Integer accessoryPrice;
    @Column(name = "afID")
    private Integer afID;
    @ManyToMany(mappedBy = "accessoryCollection")
    private Collection<Phone> phoneCollection;

    public Accessory() {
    }

    public Accessory(Integer accessoryID) {
        this.accessoryID = accessoryID;
    }

    public Integer getAccessoryID() {
        return accessoryID;
    }

    public void setAccessoryID(Integer accessoryID) {
        Integer oldAccessoryID = this.accessoryID;
        this.accessoryID = accessoryID;
        changeSupport.firePropertyChange("accessoryID", oldAccessoryID, accessoryID);
    }

    public String getAccessoryType() {
        return accessoryType;
    }

    public void setAccessoryType(String accessoryType) {
        String oldAccessoryType = this.accessoryType;
        this.accessoryType = accessoryType;
        changeSupport.firePropertyChange("accessoryType", oldAccessoryType, accessoryType);
    }

    public String getAccessoryStandard() {
        return accessoryStandard;
    }

    public void setAccessoryStandard(String accessoryStandard) {
        String oldAccessoryStandard = this.accessoryStandard;
        this.accessoryStandard = accessoryStandard;
        changeSupport.firePropertyChange("accessoryStandard", oldAccessoryStandard, accessoryStandard);
    }

    public String getAccessoryInfo() {
        return accessoryInfo;
    }

    public void setAccessoryInfo(String accessoryInfo) {
        String oldAccessoryInfo = this.accessoryInfo;
        this.accessoryInfo = accessoryInfo;
        changeSupport.firePropertyChange("accessoryInfo", oldAccessoryInfo, accessoryInfo);
    }

    public Integer getAccessoryPrice() {
        return accessoryPrice;
    }

    public void setAccessoryPrice(Integer accessoryPrice) {
        Integer oldAccessoryPrice = this.accessoryPrice;
        this.accessoryPrice = accessoryPrice;
        changeSupport.firePropertyChange("accessoryPrice", oldAccessoryPrice, accessoryPrice);
    }

    public Integer getAfID() {
        return afID;
    }

    public void setAfID(Integer afID) {
        Integer oldAfID = this.afID;
        this.afID = afID;
        changeSupport.firePropertyChange("afID", oldAfID, afID);
    }

    public Collection<Phone> getPhoneCollection() {
        return phoneCollection;
    }

    public void setPhoneCollection(Collection<Phone> phoneCollection) {
        this.phoneCollection = phoneCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (accessoryID != null ? accessoryID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Accessory)) {
            return false;
        }
        Accessory other = (Accessory) object;
        if ((this.accessoryID == null && other.accessoryID != null) || (this.accessoryID != null && !this.accessoryID.equals(other.accessoryID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "impss.Accessory[accessoryID=" + accessoryID + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
